import Vue from "vue"
import VueRouter from "vue-router"
// 1. 定义 (路由) 组件,可以从其他文件 import 进来
import Home from "@/views/Home"
import User from "@/views/User"
import Main from "@/views/Main"
import Mall from "@/views/Mall"
import PageOne from "@/views/PageOne"
import PageTwo from "@/views/PageTwo"
import Login from '@/views/Login'

Vue.use(VueRouter)

// 2. 定义路由
const routes = [
	// 首页路由
	{
		path: "/",
		component: Main, // 主路由
		redirect: "/home", //重定向
		children: [
			{ path: "home", name:"home", component: Home }, //首页
			{ path: "user", name:"user", component: User }, //用户管理
			{ path: "mall", name:"mall", component: Mall }, //商品管理
			{ path: "page1", name:"page1", component: PageOne }, //商品管理
			{ path: "page2", name:"page2", component: PageTwo }, //商品管理
		],
	},
	// 登录页面
	{
		path: '/login',
		component: Login
	}
]

// 3. 创建 router 实例
const router = new VueRouter({
	routes, // (缩写) 相当于 routes: routes
})

export default router
